home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS04.ADF
/
text
/
printer.early
< prev
next >
Wrap
Text File
|
1985-11-03
|
75KB
|
2,097 lines
/* printer.doc */
DISCLAIMER:
This file is called printer.early in that
a. it hasnt been reviewed.
b. the C language examples in this first part, the
tutorial, are adaptations from a file called
pio.c, also a part of this early output; the
adaptations have not been tested and early users
should utilize pio.c routines in place of what
is in this front section.
c. comments and questions are requested.
Rob Peck
10/30/85
Printer Device
INTRODUCTION
There are four basic ways of doing output to a printer on the Amiga
computer. The features and advantages of each are listed below:
PRT:
This is the printer device. By setting your user preferences
you can direct the output to either a serial or parallel printer.
This is, in effect, the generic printer configured on the system.
You may print (output) escape sequences to PRT: to specify the
options you want. The escape sequences you send it are interpreted
by the printer driver and (possibly different) escape sequences are
forwarded to the printer. The is by far the easiest method for most
applications. "PRT:" may be opened just like anyother AmigaDOS file.
SER:
This is the serial device. If you "know" that the printer is
connected to the serial port (you shouldn't) and you "know"
what kind of printer it is (again, you shouldn't) then you
could use AmigaDOS to open "SER:" and output characters to it,
causing it to print. THIS BEHAVIOR IS STRONGLY DISCOURAGED!
Characters you send are not examined or converted.
PAR:
This is the parallel device. Same warnings as SER: apply.
printer.device
By opening the printer.device directly, you have full control
over the printer. You can either send escape sequences as shown
in the command definitions table below for printer control, or
call the RawWrite routine to send raw characters directly to your
printer with no processing at all. Using this technique would be
similar to sending raw characters to SER: or PAR: from AmigaDOS,
(but you don't need to know which one has the printer connected.)
PRINTER DEVICE OUTPUT
The printer device can be thought of as kind of a filter, in that some
printers respond in one way to a command output and some respond in
another. The printer device, as a generic printer, recognizes command
sequences and, depending on the printer-dependent configuration that is
currently loaded (by the Preferences tool), either ignores them or
perhaps translates them into an entirely different sequence that this
printer can actually understand and obey.
This chapter deals with these basic topics:
o Setting up for printer I/O (creating an I/O request structure)
o Writing to the printer to control its behavior
o Writing characters or causing a graphics dump to a graphics capable printer
o Closing the printer device.
o An advanced topic section that covers creating your own printer device
driver.
This section shows you how to set up for printer I/O.
CREATING AN I/O REQUEST
Printer I/O, like other devices, requires that you create an I/O request
message that you pass to the printer device for processing. The message
contains the command, as well as a data area. In the data area, for a
write, will be a pointer to the stream of information you wish to write
to the printer.
Here is a program fragment that can be used to create the message block
that you use for printer communications.
For communicating with the printer:
struct IOStdReq *printerMsg; /* I/O request block pointer */
struct Port *printerPort; /* a port at which to receive */
printerPort = CreatePort("print.port",0);
if(printerPort == 0) exit(100); /* error in createport */
printerMsg = CreatePrinterIO(printerPort);
if(printerMsg == 0) exit(200); /* error in createprinterio */
The routine CreatePort is part of amiga.lib.
Note that there are two additional kinds of I/O request blocks that, for
some commands, must be prepared for sending to the printer. The first
is called IODRPReq, and the second is called IOPrtCmdReq. Both are
outlined in the include-file "devices/printer.h". A routine called
CreatePrinterIO() is included at the back of this chapter and can be
utilized to allocate memory for such structures. It corresponds to
CreateStdIO for creating a pointer to a message-passing data structure.
A routine named DeletePrinterIO() is provided as well, to deallocate
the memory that CreatePrinterIO() allocated.
OPENING A PRINTER DEVICE
To open a path to the printer device, you open it using a routine such
as the following:
int
OpenPrinter(request)
printerIO *request;
{
return(OpenDevice("printer.device",0,request,0));
}
This routine returns a value of zero if the printer device was opened
successfully and a value other than zero if it did not open.
Note that the data structure type "printerIO" is a C-language union defined
as:
union {
struct IOStdReq ios;
struct IODRPReq iodrp;
struct IOPrtCmdReq iopc;
} printerIO;
This means that one memory area can be used to represent three distinct
forms of memory layout, for the three different types of data structures
that must be used to pass commands to the printer device. Some of the
commands are simple, and can use an IOStdReq. Some of the commands
require many more parameters and extend the basic I/O request block
accordingly.
WRITING TO THE PRINTER
There are three forms involved in writing to the printer. The first uses
a character stream that you create, possibly containing escape sequences to
be processed by the printer driver (PrinterWrite example) or containing
just about anything else that is to be passed directly to the printer
(PrinterRaw example). The second form of write passes a command to the
printer(PrinterCmd example). The third form asks for a graphics dump of
a drawing area (PrinterDump example).
To write to the printer, you pass to the printer device the system standard
command CMD_WRITE. Here are routines that can be used to send this command.
/* Send a NULL terminated string to the printer */
/* Assumes printer device is open and printerMsg
* is correctly initialized. Watches for embedded
* "escape-sequences" and handles them as defined.
*/
int
PrinterWrite(request,string)
char *string;
printerIO *request;
{
int count;
char *b;
s = string;
count = 0;
while (*s++ != '\0') count++;
/* queue a printer write */
request->ios.io_Command = CMD_WRITE;
request->ios.io_Data = buffer;
request->ios.io_Length = count;
return(DoIO(request));
}
/* Send RAW character stream to the printer directly,
* avoid "escape-sequence" parsing by the device.
* Also a NULL terminated stream.
*/
int
PrintRaw(request,buffer)
char *buffer;
printerIO *request;
{
int count;
char *b;
b = buffer;
count = 0;
while (*b++ != '\0') count++;
/* queue a printer raw write */
request->ios.io_Command = PRD_RAWWRITE;
request->ios.io_Data = buffer;
request->ios.io_Length = count;
return(DoIO(request));
}
Printer Command Definitions
The following table describes the supported printer functions.
You can use the escape sequences with PRT: and the printer.device.
In order to use the Name or command numbers you need to open the
printer.library directly.
Again, recall that SER: and PAR: will ignore all of these and pass
them directly on to the attached device.
Cmd Escape Defined
Name No. sequence Function by:
------- --- -------- ------------------- -------
aRIS 0 ESCc reset ISO
aRIN 1 ESC#1 initialize +++
aIND 2 ESCD lf ISO
aNEL 3 ESCE return,lf ISO
aRI 4 ESCM reverse lf ISO
aSGR0 5 ESC[0m normal char set ISO
aSGR3 6 ESC[3m italics on ISO
aSGR23 7 ESC[23m italics off ISO
aSGR4 8 ESC[4m underline on ISO
aSGR24 9 ESC[24m underline off ISO
aSGR1 10 ESC[1m boldface on ISO
aSGR22 11 ESC[22m boldface off ISO
aSFC 12 ESC[30m set foreground color ISO
(range is 30-39)
aSBC 13 ESC[40m set background color ISO
(range is 40-49)
aSHORP0 14 ESC[0w normal pitch DEC
aSHORP2 15 ESC[2w elite on DEC
aSHORP1 16 ESC[1w elite off DEC
aSHORP4 17 ESC[4w condensed fine on DEC
aSHORP3 18 ESC[3w condensed off DEC
aSHORP6 19 ESC[6w enlarged on DEC
aSHORP5 20 ESC[5w enlarged off DEC
aDEN6 21 ESC[6"z shadow print on DEC (sort of)
aDEN5 22 ESC[5"z shadow print off DEC
aDEN4 23 ESC[4"z doublestrike on DEC
aDEN3 24 ESC[3"z doublestrike off DEC
aDEN2 25 ESC[2"z NLQ on DEC
aDEN1 26 ESC[1"z NLQ off DEC
aSUS2 27 ESC[2v superscript on +++
aSUS1 28 ESC[1v superscript off +++
aSUS4 29 ESC[4v subscript on +++
aSUS3 30 ESC[3v subscript off +++
aSUS0 31 ESC[0v normalize the line +++
aPLU 32 ESCL partial line up ISO
aPLD 33 ESCK partial line down ISO
aFNT0 34 ESC(B US char set DEC
aFNT1 35 ESC(R French char set DEC
aFNT2 36 ESC(K German char set DEC
aFNT3 37 ESC(A UK char set DEC
aFNT4 38 ESC(E Danish I char set DEC
aFNT5 39 ESC(H Swedish char set DEC
aFNT6 40 ESC(Y Italian char set DEC
aFNT7 41 ESC(Z Spanish char set DEC
aFNT8 42 ESC(J Japanese char set +++
aFNT9 43 ESC(6 Norweign char set DEC
aFNT10 44 ESC(C Danish II char set +++
aPROP2 45 ESC[2p proportional on +++
aPROP1 46 ESC[1p proportional off +++
aPROP0 47 ESC[0p proportional clear +++
aTSS 48 ESC[n E set proportional offset ISO
aJFY5 49 ESC[5 F auto left justify ISO
aJFY7 50 ESC[7 F auto right justify ISO
aJFY6 51 ESC[6 F auto full justify ISO
aJFY0 52 ESC[0 F auto justify off ISO
aJFY3 53 ESC[3 F letter space (justify) ISO (special)
aJFY1 54 ESC[1 F word fill(auto center) ISO (special)
aVERP0 55 ESC[0z 1/8" line spacing +++
aVERP1 56 ESC[1z 1/6" line spacing +++
aSLPP 57 ESC[nt set form length n DEC
aPERF 58 ESC[nq perf skip n (n>0) +++
aPERF0 59 ESC[0q perf skip off +++
aLMS 60 ESC#9 Left margin set +++
aRMS 61 ESC#0 Right margin set +++
aTMS 62 ESC#8 Top margin set +++
aBMS 63 ESC#2 Bottom marg set +++
aSTBM 64 ESC[n1;n2r T&B margins DEC
aSLRM 65 ESC[n1;n2s L&R margin DEC
aCAM 66 ESC#3 Clear margins +++
aHTS 67 ESCH Set horiz tab ISO
aVTS 68 ESCJ Set vertical tabs ISO
aTBC0 69 ESC[0g Clr horiz tab ISO
aTBC3 70 ESC[3g Clear all h tab ISO
aTBC1 71 ESC[1g Clr vertical tabs ISO
aTBC4 72 ESC[4g Clr all v tabs ISO
aTBCALL 73 ESC#4 Clr all h & v tabs +++
aTBSALL 74 ESC#5 Set default tabs +++
aEXTEND 75 ESC[n"x extended commands +++
Legend:
-------
ISO indicates that the sequence has been defined by the
International Standards Organization. This is
also very similar to ANSII x3.64
DEC indicates a control sequence defined by Digital
Equipment Corperation.
+++ indicates a sequence unique to Amiga.
n in the table above, a lower case n stands for a decimal
number, expressed as a set of ascii digits, for example
"12".
ADVANCED SECTION - CREATING A PRINTER DRIVER
Creating a printer dependent code fragment for the printer device involves
writing the data structures and code needed, compiling and assembling it, and
linking it to produce an amiga object binary file such that the first hunk in
that file is the PrinterSegment structure described in devices/prtbase.[hi]
(which is pointed to by the BPTR returned by the LoadSeg of the object file).
The user specifies the printer dependent object file to load by specifying
Custom printer in preferences, and filling in the Custom Printer Name with the
name of the object file (relative to the directory DEVS:printers/).
The printer dependent code PrinterSegment contains the PrinterExtendedData
(PED) structure (also described in devices/prtbase.[hi]) at the beginning of
the object. The PED structure contains data describing the capabilities of the
printer, as well as pointers to code and other data. Here is the assembly code
for a sample PrinterSegment, which would be linked to the beginning of the
sequence of files describing the printer dependent code fragment.
**********************************************************************
*
* printer device dependent code tag
*
**********************************************************************
; named sections are easier to exactly place in the linked file
SECTION custom
*------ Included Files -----------------------------------------------
INCLUDE "exec/types.i"
INCLUDE "exec/nodes.i"
INCLUDE "revision.i" ; contains VERSION & REVISION
INCLUDE "devices/prtbase.i"
*------ Imported Names -----------------------------------------------
XREF _Init
XREF _Expunge
XREF _Open
XREF _Close
XREF _CommandTable
XREF _DoSpecial
XREF _Render
*------ Exported Names -----------------------------------------------
XDEF _PEDData
**********************************************************************
; in case anyone tries to execute this
MOVEQ #0,D0
RTS
DC.W VERSION
DC.W REVISION
_PEDData:
DC.L printerName
DC.L _Init
DC.L _Expunge
DC.L _Open
DC.L _Close
DC.B PPC_BWGFX ; PrinterClass
DC.B PCC_BW ; ColorClass
DC.B 80 ; MaxColumns
DC.B 1 ; NumCharSets
DC.W 8 ; NumRows
DC.L 960 ; MaxXDots
DC.L 0 ; MaxYDots
DC.W 120 ; XDotsInch
DC.W 82 ; YDotsInch
DC.L _CommandTable ; Command Strings
DC.L _DoSpecial ; Command Code
DC.L _Render ; Graphics Render
DC.L 30 ; Timeout
printerName:
DC.B 'Custom Printer Name'
DC.B 0
EVEN
The printer name should be the brand name of the printer that is available for
use by programs wishing to be specific about the printer name in any diagnostic
or instruction messages. The four functions at the top of the structure are
used to initialize this printer depentent code:
(*(PED->ped_Init))(PD);
is called when the printer dependent code is loaded, and provides a
pointer to the printer device for use by the printer dependent code.
It can also be used to open up any libraries or devices needed by the
printer dependent code.
(*(PED->ped_Expunge))();
is called immediately before the printer dependent code is unloaded, to
allow it to close any resources obtained at initialization time.
(*(PED->ped_Open))(ior);
is called in the process of an OpenDevice call, after the preferences
are read and the correct primitive IO device (parallel or serial) is
opened. It must return zero if the open is successful, or non-zero to
terminate the open and return an error to the user.
(*(PED->ped_Close))(ior);
is called in the process of a CloseDevice call, to allow the printer
dependent code to close any resources obtained at open time.
The PD variable provided as a parameter to the initialization call is a pointer
to the PrinterData structure described in devices/prtbase.[hi]. This is also
the same as the io_Device entry in printer IO requests.
pd_SegmentData
points back to the PrinterSegment, which contains the PED.
pd_PrintBuf
is available for use by the printer dependent code -- it is not
otherwise used by the printer device.
(*pd_PWrite)(data, length);
is the interface routine to the primitive IO device. This routine uses
two IO requests to the primitive device, so writes are double-buffered.
The data parameter points to the byte data to send, and the length is
the number of bytes.
(*pd_PBothReady)();
waits for both primitive IO requests to complete. This is useful if
your code does not want to use double buffering -- if you want to use
the same data buffer for successive pd_PWrites, you must seperate them
with a call to this routine.
pd_Preferences
is the copy of preferences in use by the printer device, obtained when
the printer was opened.
The timeout field is the number of seconds that an I/O request from the printer
device will remain posted and unsatisfied to the primitive IO device (parallel
or serial) before the timeout requestor is presented to the user. This value
should be large enough to avoid the requestor during normal printing.
The developer's document for how to write a graphics printer driver
includes files called render.c and printertag.asm. These are files
you create for a custom printer driver. Four files for four different
types of printers are contained in this document, for the following:
diablo_c - an example of a ymcb color printer
epson - an example of a b/w printer
okimate20 - an example of a ymc_bw printer (has two render,c functions)
hpplus - an example of a single sheet multiple density printer
Writing a Custom Graphics Printer Driver for the AMIGA
------------------------------------------------------
Designing a custom graphics printer driver consists of 2 steps;
writing a specific render.c function, and replacing the printer specific
values in printertag.asm.
RENDER.C
--------
This function is the main printer specific code module and consists of
6 parts; (0)master initialization, (1)pixel rendering, (2)dumping a pixel buffer
to the printer, (3)clearing and initializing the pixel buffer, (4)closing down,
and (5)density selection.
1. Master Initialization (case 0)
When this call is made you must use PC to define values for ROWSIZE,
COLORSIZE(only on color printers), BUFSIZE, and colors[] (only on color
printers). PC is the maximum number of Print Columns or pixels per row
that the dump program is going to send to you. Note that the
graphic driver uses double buffering, that is why the
AllocMem call allocs BUFSIZE*2 ubytes. You are also expected to reset
the printer and any other initial initialization required.
2. Render Pixel (case 1)
When this call is made, you will be passed the x,y position of the pixel
and its color type. You are expected to put the pixel in the proper place
in the buffer. The color types are; 0-black, 1-yellow, 2-magenta, and
3-cyan.
3. Dump Buffer to Printer (case 2)
When this call is made, you must send the buffer to the printer. AS IT NOW
STANDS, YOU SHOULD NEVER NEED TO CHANGE THIS ROUTINE. IT SHOULD BE COMMON TO
ALL PRINTERS, IT S MPLY SENDS THE BUFFER THAT YOU HAVE BEEN FILLING (VIA
CASE 1) TO THE PRINTER.
4. Clear and Init the Buffer (case 3)
This consists of two parts, clearing the buffer and initing the buffer.
Clearing the buffer should be the same for all printers. Initing the
buffer is printer specific and it includes placing the printer specific
control code in the buffer ahead and behind of where the data will go.
5. Closing Down (case 4)
When this call is made you must wait for the print buffers to clear and
then de-allocate the memory. AS IT NOW STANDS, YOU SHOULD NEVER NEED TO
CHANGE THIS ROUTINE. IT SHOULD BE COMMON TO ALL PRINTERS, IT SIMPLY WAITS
FOR BOTH BUFFERS TO EMPTY AND THEN DE-ALLOCATES THE MEMORY.
6. Density Selection (case 5)
Currently this option is implemented only on the HPLaserJet and
HPLaserJet PLUS printer(s), although the call is made to each printer
specific driver. Ignoring it causes no problems as the call is made simply
to give you a chance to select a different density from the default one.
You should note that this call is
made BEFORE the master initialization call and gives you a chance to alter
any variables which the MI may use to program the printer.
PRINTERTAG.ASM
--------------
The printer specific values that need to be filled in here are:
1. MaxXDots - the maximum # of dots the printer can print across the page.
2. MaxYDots - the maximum # of dots the printer can print down the page.
Generally, if the printer supports roll or form feed paper then this
value should be 0 indicating that there is no limit. If the printer has a
definte y dots maximum (as the HPLaserJet) then this number should be
entered here.
3. XDotsInch - the dot density in x (ie. 120 dpi).
4. YDotsInch - the dot density in y (ie. 144 dpi).
5. PrinterClass - the printer class the printer falls into.
Current choices are:
PPC_BWALPHA - alphanumeric, no graphics.
PPC_BWGFX - black&white (only) graphics.
PPC_COLORGFX - color (and maybe b/w) graphics.
6. ColorClass - the color class the printer falls into.
Current choices are:
PCC_BW - Black&White only.
PCC_YMC - Yellow Magenta Cyan only.
PCC_YMC_BW - " or Black&White but not both (like the Okimate 20).
PCC_YMCB - YellowMagentaCyanBlack.
Below is a description of the alpha section. It is meant to
be read with the alpha listing for the EpsonX80 and Diablo Adv 25
close at hand.
The alphanumeric portion of the printer driver is designed to convert
ANSI x3.64 style commands into the specific escape codes required by
each individual printer. For example, the ANSI code for italics on
is ESC[3m . The Epson FX80 printer would like a ESC%G to turn italics
italics, while the Diablo Advantage D25 might like something different.
By using the printer driver all printers may be handled in a similar manner.
There are two parts to the alphanumeric portion of the printer driver:
The CommandTable data table, and the DoSpecial() routine.
The CommandTable is used to convert all escape codes which can be handled by
simple substitution. There is one entry per ANSI command supported. The
order of the commands is given in the printer.h file. By placing the specific
codes for your printer in the proper position, the conversion takes place
automatically.
NOTE: if the code for your printer requires a decimal 0 (an ASCII NUL
character) , this is entered into the Command Table as an octal 376 (decimal
254).
Placing an octal value of 377 (255 decimal) in a position in the command
table indicates to the printer device that no simple conversion is available
on this printer for this ANSI command. For example, if a printer does not
support one of the functions (i.e. if a daisy wheel printer does not have a f
oreign character set), 377 octal (255 decimal) is placed in that position.
However, 377 in a position can also mean that the ANSI function is to be
handled by code located in the DOSPECIAL function.
The DoSpecial function is meant to implement all the ANSI functions
which can't be done by simple conversion, but which the printer
is capable of. These are functions which need parameter conversion,
read values from preferences, etc.
The DoSpecial function is set up as follows:
#include "exec/types.h"
#include "../printer/printer.h"
#include "../printer/prtbase.h"
extern struct PrinterData *PD;
DoSpecial(command,outputBuffer,vline,currentVMI,crlfFlag,Parms)
char outputBuffer[];
UWORD *command;
BYTE *vline;
BYTE *currentVMI;
BYTE *crlfFlag;
UBYTE Parms[];
{
The command number will be in *command. The file printer.h contains
the definitions for the routines to use (i.e. aRIN is initialize, etc.)
The current line position will be in vline.
the current line spacing will in currentVMI.
crlfFlag contains the setting of the 'Add line feed after carriage return
flag'
Parms contain whatever parameters were given with the ANSI command.
outputBuffer is the buffer where the converted command is returned.
flag.
Parms contain whatever parameters were given with the ANSI command.
outputBuffer is the buffer where the converted command is returned.
Almost every printer will require a aRIN (initialize) command in DoSpecial.
This command reads the printer settings from preferences, and makes
the proper control sequence for the specific printer. Also, it returns
the character set to normal (not italicized, not bold, etc).
Other functions depend on the printer.
Certain functions are implemented both in the CommandTable and the
DoSpecial routine. Those are functions like superscript, subscript,
PLU (partial line up) and PLD (partial line down) which can often
be handled by a simple conversion, but must adjust the printer
devices line position variable.
FOLLOWING IS ORIGINAL FILE BEING ADAPTED PER INFORMATION IN DISCLAIMER.
PRIMARY REASON FOR ADAPTATION IS CONSISTENCY IN APPROACH WITH REST OF
REWRITE OF ROM KERNEL MANUAL.
/*********************************************************************/
/* */
/* Copyright (c) 1985 */
/* Commodore-Amiga, Inc. */
/* All rights reserved. */
/* */
/* No part of this program may be reproduced, transmitted, */
/* transcribed, stored in retrieval system, or translated */
/* into any language or computer language, in any form or */
/* by any means, electronic, mechanical, magnetic, optical, */
/* chemical, manual or otherwise, without the prior written */
/* permission of: */
/* Commodore-Amiga, Inc. */
/* 983 University Ave #D */
/* Los Gatos, CA. 95030 */
/* */
/*********************************************************************/
#include "exec/types.h"
#include "exec/nodes.h"
#include "exec/lists.h"
#include "exec/ports.h"
#include "exec/tasks.h"
#include "exec/io.h"
#include "devices/printer.h"
union {
struct IOStdReq ios;
struct IODRPReq iodrp;
struct IOPrtCmdReq iopc;
} printerIO;
struct MsgPort replyMsgPort;
int pOpen(signal) /* open the printer */
int signal;
{
int error;
if ((error = OpenDevice("printer.device", 0, &printerIO, 0)) != 0)
return(error);
/* set up the message port in the I/O request */
replyMsgPort.mp_Node.ln_Type = NT_MSGPORT;
replyMsgPort.mp_Node.ln_Name = "PIO";
replyMsgPort.mp_Flags = 0;
replyMsgPort.mp_SigBit = signal;
replyMsgPort.mp_SigTask = (struct Task *) FindTask((char *) NULL);
AddPort(&replyMsgPort);
printerIO.ios.io_Message.mn_ReplyPort = &replyMsgPort;
return(0);
}
pClose() /* close the printer */
{
CloseDevice(&printerIO);
RemPort(&replyMsgPort);
}
int
pDumpRPort(rastPort, colorMap, modes, sx,sy, sw,sh, dc,dr, s)
struct RastPort *rastPort;
struct ColorMap *colorMap;
ULONG modes;
UWORD sx, sy, sw, sh;
LONG dc, dr;
UWORD s;
{
printerIO.iodrp.io_Command = PRD_DUMPRPORT;
printerIO.iodrp.io_RastPort = rastPort;
printerIO.iodrp.io_ColorMap = colorMap;
printerIO.iodrp.io_Modes = modes;
printerIO.iodrp.io_SrcX = sx;
printerIO.iodrp.io_SrcY = sy;
printerIO.iodrp.io_SrcWidth = sw;
printerIO.iodrp.io_SrcHeight = sh;
printerIO.iodrp.io_DestCols = dc;
printerIO.iodrp.io_DestRows = dr;
printerIO.iodrp.io_Special = s;
return(DoIO(&printerIO));
}
int
pWrite(buffer) /* write to the printer */
char *buffer;
{
int count;
char *b;
b = buffer;
count = 0;
while (*b++ != '\0') count++;
/* queue a printer write */
printerIO.ios.io_Command = CMD_WRITE;
printerIO.ios.io_Data = buffer;
printerIO.ios.io_Length = count;
return(DoIO(&printerIO));
}
int
pRawWrite(buffer) /* write to the printer w/o escape parsing */
char *buffer;
{
int count;
char *b;
b = buffer;
count = 0;
while (*b++ != '\0') count++;
/* queue a printer raw write */
printerIO.ios.io_Command = PRD_RAWWRITE;
printerIO.ios.io_Data = buffer;
printerIO.ios.io_Length = count;
return(DoIO(&printerIO));
}
pPrtCommand(command, p0, p1, p2, p3) /* perform a printer command */
int command, p0, p1, p2, p3;
{
/* queue a printer command */
printerIO.iopc.io_Command = PRD_PRTCOMMAND;
printerIO.iopc.io_PrtCommand = command;
printerIO.iopc.io_Parm0 = p0;
printerIO.iopc.io_Parm1 = p1;
printerIO.iopc.io_Parm2 = p2;
printerIO.iopc.io_Parm3 = p3;
return(DoIO(&printerIO));
}
FOLLOWING ARE THE RENDER.C FILES AND PRINTERTAG.ASM FILES REFERENCED ABOVE:
/*********************************************************************/
#include <exec/types.h>
#include <exec/nodes.h>
#include <exec/lists.h>
#include <exec/memory.h>
#include "../printer/prtbase.h"
extern struct PrinterData *PD;
/* for the DIABLO C-150 */
int Render(ct, x, y, status, pc) /* passed a color type */
UBYTE ct; /* the color type to use (0, 1, 2 or 3) */
UWORD x, y; /* the x & y co-ordinates */
UBYTE status; /* print status (0-init, 1-enter pixel, 2-dump) */
UWORD pc; /* the # of print columns (ie. pixels) */
{
static UWORD ROWSIZE;
static UWORD COLORSIZE;
static UWORD BUFSIZE;
static UWORD colors[4]; /* color ptrs */
static BYTE huns,tens,ones; /* used to program buffer size */
static UWORD bufptr; /* used for double buffering; points to buffer 1 or 2 */
UWORD i; /* mics. var */
BYTE err; /* the error # */
switch(status)
{
case 0 : /* alloc memory for printer buffer (uses double buffering) */
ROWSIZE=(pc+7)/8; /* pc/8 pixels per row on the DIABLO C-150 */
huns=ROWSIZE/100;
tens=(ROWSIZE-huns*100)/10;
ones=(ROWSIZE-huns*100-tens*10);
ROWSIZE += 7; /* plus 7 cmd bytes */
COLORSIZE=(ROWSIZE*4); /*the size of each color buffer */
BUFSIZE=(COLORSIZE*4+3); /* buffer size required for DIABLO C-150 */
colors[0] = 7; /* black */
colors[1] = COLORSIZE*2+7; /* yellow */
colors[2] = COLORSIZE+7; /* magenta */
colors[3] = COLORSIZE*3+7; /* cyan */
PD->pd_PrintBuf = (UBYTE *)
AllocMem(BUFSIZE*2,MEMF_PUBLIC); /* alloc public mem */
if (err=(PD->pd_PrintBuf==0)) return(err);
if (err=(*(PD->pd_PWrite))("\033\rP",3)) return(err); /* reset printer to power-up */
if (err=(*(PD->pd_PWrite))("\033l5\r",4)) return(err); /* set l margin to .5 inch. */
if (err=(*(PD->pd_PWrite))("\033r90\r",5)) return(err); /* set r margin to 9 inch. */
bufptr=0; /* init to first buffer */
return(0); /* flag all ok */
break;
case 1 : /* put pixel in buffer */
i = bufptr+x/8+(y&3)*ROWSIZE+colors[ct]; /* calc which byte to use */
PD->pd_PrintBuf[i] = PD->pd_PrintBuf[i] | (1 << (7-(x&7))); /* fill print buffer */
return(0); /* flag all ok */
break;
case 2 : /* dump buffer to printer */
if (err=(*(PD->pd_PWrite))(&(PD->pd_PrintBuf[bufptr]), BUFSIZE)) return(err);
bufptr=BUFSIZE-bufptr; /* switch to other buffer */
return(0); /* flag all ok */
break;
case 3 : /* clear and init buffer */
for (i=bufptr; i<BUFSIZE+bufptr; i++)
PD->pd_PrintBuf[i] = 0; /* clear buffer */
for (i=0; i<16; i++) {
PD->pd_PrintBuf[bufptr+i*ROWSIZE] = 27;
PD->pd_PrintBuf[bufptr+i*ROWSIZE+1] = 'g';
PD->pd_PrintBuf[bufptr+i*ROWSIZE+2] = i+'0';
PD->pd_PrintBuf[bufptr+i*ROWSIZE+3] = huns + '0';
PD->pd_PrintBuf[bufptr+i*ROWSIZE+4] = tens + '0';
PD->pd_PrintBuf[bufptr+i*ROWSIZE+5] = ones + '0';
PD->pd_PrintBuf[bufptr+i*ROWSIZE+6] = ','; /* select # of bytes for each line */
}
PD->pd_PrintBuf[bufptr+BUFSIZE-3] = 27;
PD->pd_PrintBuf[bufptr+BUFSIZE-2] = 'k';
PD->pd_PrintBuf[bufptr+BUFSIZE-1] = '1';
return(0); /* flag all ok */
break;
case 4 : /* free the print buffer memory */
err=(*(PD->pd_PBothReady))(); /* wait for both buffers to be clear */
FreeMem(PD->pd_PrintBuf,BUFSIZE*2); /* free the print buffers memory */
return(err); /* return status */
break;
default : return(0); /* flag all ok */
}
}
TTL '$Header: printertag.asm,v 1.2 85/10/09 23:57:10 kodiak Exp $'
**********************************************************************
* *
* Copyright 1985, Commodore-Amiga Inc. All rights reserved. *
* No part of this program may be reproduced, transmitted, *
* transcribed, stored in retrieval system, or translated into *
* any language or computer language, in any form or by any *
* means, electronic, mechanical, magnetic, optical, chemical, *
* manual or otherwise, without the prior written permission of *
* Commodore-Amiga Incorporated, 983 University Ave. Building #D, *
* Los Gatos, California, 95030 *
* *
**********************************************************************
*
* printer device dependent code tag
*
* Source Control
* --------------
* $Header: printertag.asm,v 1.2 85/10/09 23:57:10 kodiak Exp $
*
* $Locker: $
*
* $Log: printertag.asm,v $
* Revision 1.2 85/10/09 23:57:10 kodiak
* replace reference to pdata w/ prtbase
*
* Revision 1.1 85/09/25 18:45:12 kodiak
* double timeout: alpha is too slow to print 400 chars in 30 sec.
*
* Revision 1.0 85/09/25 18:32:57 kodiak
* added to rcs for updating in version 1
*
* Revision 25.1 85/06/16 01:02:15 kodiak
* *** empty log message ***
*
* Revision 25.0 85/06/15 06:40:00 kodiak
* added to rcs
*
* Revision 25.0 85/06/13 18:53:36 kodiak
* added to rcs
*
*
**********************************************************************
SECTION printer
*------ Included Files -----------------------------------------------
INCLUDE "exec/types.i"
INCLUDE "exec/nodes.i"
INCLUDE "exec/strings.i"
INCLUDE "diablo_c_rev.i"
INCLUDE "../printer/prtbase.i"
*------ Imported Names -----------------------------------------------
XREF _Init
XREF _Expunge
XREF _Open
XREF _Close
XREF _CommandTable
XREF _PrinterSegmentData
XREF _DoSpecial
XREF _Render
*------ Exported Names -----------------------------------------------
XDEF _PEDData
**********************************************************************
MOVEQ #0,D0 ; show error for OpenLibrary()
RTS
DC.W VERSION
DC.W REVISION
_PEDData:
DC.L printerName
DC.L _Init
DC.L _Expunge
DC.L _Open
DC.L _Close
DC.B PPC_COLORGFX ; PrinterClass
DC.B PCC_YMCB ; ColorClass
DC.B 80 ; MaxColumns
DC.B 1 ; NumCharSets
DC.W 4 ; NumRows
DC.L 1024 ; MaxXDots
DC.L 0 ; MaxYDots
DC.W 120 ; XDotsInch
DC.W 120 ; YDotsInch
DC.L _CommandTable ; Commands
DC.L _DoSpecial
DC.L _Render
DC.L 60 ; twice normal: slow alpha
printerName:
STRING <'Diablo C-150'>
END
/* diablo C-150 command table */
/****** printer.device/printers/Diablo_C-150_functions *****************
*
* NAME
* Diablo C-150 functions implemented:
*
* aRIS, aIND, aNEL,
* aSLPP, aLMS, aRMS,
* aHTS, aTBC0, aTBC3, aTBCALL, aTBSALL
*
* special functions implemented:
* aRIN aSLRM aSFC
*
************************************************************************/
char *CommandTable[]={
"\033\015P", /*reset RIS ESCc */
"\377", /*initialize*/
"\012", /* lf IND ESCD */
"\015\012", /* return,lf NEL ESCE */
"\377", /* reverse lf RI ESCM */
"\377", /*normal char set SGR 0 ESC[0m */
"\377", /*italics on SGR 3 ESC[3m */
"\377", /*italics off SGR 23 ESC[23m */
"\377", /*underline on SGR 4 ESC[4m */
"\377", /*underline off SGR 24 ESC[24m */
"\377", /*boldface on SGR 1 ESC[1m */
"\377", /*boldface off SGR 22 ESC[22m */
"\377", /* set foreground color */
"\377", /* set background color */
"\377", /*normal space DECSHORP ESC[0w */
"\377", /*elite on DECSHORP ESC[2w */
"\377", /*elite off DECSHORP ESC[1w */
"\377", /* fine on */
"\377", /* fine off */
"\377", /*enlarged on GSM (special) */
"\377", /*enlarged off GSM (special) */
"\377", /*shadow print on*/
"\377", /*shadow print off*/
"\377", /*doublestrike on*/
"\377", /*doublestrike off*/
"\377", /* NLQ on*/
"\377", /* NLQ off*/
"\377", /*superscript on PLU ESCL */
"\377", /*superscript off PLD (special) */
"\377", /*subscript on PLD ESCK */
"\377", /*subscript off PLU (special) */
"\377", /* normalize */
"\377", /* partial line up PLU ESCL */
"\377", /* partial line down PLD ESCK */
"\377", /*US char set ESC(B */
"\377", /*French char set ESC(R */
"\377", /*German char set ESC(K */
"\377", /*UK char set ESC(A */
"\377", /*Danish I char set ESC E */
"\377", /*Sweden char set ESC(H */
"\377", /*Italian char set FNT 6 */
"\377", /*Spanish char set FNT 7 */
"\377", /*Japanese char set FNT 8 */
"\377", /*Norweigen char set FNT 9 */
"\377", /*Danish II char set*/
"\377", /*proportional on */
"\377", /*proportional off*/
"\377", /*proportional clear*/
"\377", /*set prop offset TSS */
"\377", /*auto left justify JFY 5 */
"\377", /*auto right justify JFY 7 */
"\377", /*auto full justify JFY 3,6 */
"\377", /*auto justify off JFY 0 */
"\377", /*place holder */
"\377", /*auto center on JFY 2,6 */
"\377", /* 1/8" line space DECVERP ESC[0z */
"\377", /* 1/6" line spacing DECVERP ESC[1z */
"\033\014", /* set form length DECSLPP ESC[Pnt */
"\377", /* perf skip n */
"\377", /* perf skip off */
"\0339", /* Left margin set DECSLRM ESC[Pn1;Pn2s */
" \0330", /* Right margin set */
"\377", /* Top margin set DECSTBM ESC[Pn1;Pn2r */
"\377", /* Bottom marg set */
"\377", /* T&B margin set STBM ESC[Pn1;Pn2r */
"\377", /* L&R margin set SLRM ESC[Pn1;Pn2s */
/* Clear margins */
"\033l5\015\033r90\015",
"\0331", /* Set horiz tab HTS ESCH */
"\377", /* Set vertical tab VTS ESCJ */
"\0338", /* Clr horiz tab TBC 0 ESC0g */
"\0332", /* Clear all h tabs TBC 3 ESC3g */
"\377", /* Clr vertical tab TBC 1 ESC1g */
"\377", /* Clr all v tabs TBC 4 ESC4g */
"\0332", /* Clr all h & v tabs */
/* set default tabs */
"\033i9,17,25,33,41,49,57,65,73,81,89,97,105,113,121,129",
"\377" /* extended commands */
};
/* diablo C-150 special printer functions */
/****** printer.device/printers/Diablo_C-150_special_functions **********
*
* NAME
* Diablo C-150 special functions implemented:
*
************************************************************************/
#include "exec/types.h"
#include "../printer/printer.h"
#include "../printer/prtbase.h"
extern struct PrinterData *PD;
DoSpecial(command,outputBuffer,vline,currentVMI,crlfFlag,Parms)
char outputBuffer[];
UWORD *command;
BYTE *vline;
UBYTE *currentVMI; /* used for color on this printer */
BYTE *crlfFlag;
UBYTE Parms[];
{
int x=0;
int y=0;
static BYTE ISOcolorTable[10]= {49,51,53,52,55,50,54,48,49,49};
static unsigned char initMarg[]="\033l00\015\033r00\015";
if(*command==aRIN) {
*currentVMI=0x70; /* white background, black text */
outputBuffer[x++]='\015';
outputBuffer[x++]='\012';
Parms[0]=(PD->pd_Preferences.PrintLeftMargin);
Parms[1]=(PD->pd_Preferences.PrintRightMargin);
*command=aSLRM;
}
if(*command==aSLRM) {
Parms[0]=Parms[0]+4;
if(Parms[0]<5)Parms[0]=5;
Parms[1]=Parms[1]+5;
if(Parms[1]>90)Parms[1]=90;
initMarg[2]=(char)((Parms[0]/10)+'0');
initMarg[3]=(char)((Parms[0]-(UBYTE)(Parms[0]/10)*10)+'0');
initMarg[7]=(char)((Parms[1]/10)+'0');
initMarg[8]=(char)((Parms[1]-(UBYTE)(Parms[1]/10)*10)+'0');
while(y<10)outputBuffer[x++]=initMarg[y++];
return(x);
}
if(*command==aSFC)
{
if(Parms[0]==39)Parms[0]=30; /* set defaults */
if(Parms[0]==49)Parms[0]=47;
if(Parms[0]<40) *currentVMI=((*currentVMI)&240)+(Parms[0]-30);
else *currentVMI=((*currentVMI)&15)+((Parms[0]-40)*16);
outputBuffer[x++]='\033';
outputBuffer[x++]='@';
outputBuffer[x++]=ISOcolorTable[(*currentVMI)&15];
outputBuffer[x++]=ISOcolorTable[(((*currentVMI)&240)/16)];
return(x);
}
return(0);
}
/*********************************************************************/
#include <exec/types.h>
#include <exec/nodes.h>
#include <exec/lists.h>
#include <exec/memory.h>
#include "../printer/prtbase.h"
extern struct PrinterData *PD;
/* for the EPSON */
int Render(ct, x, y, status, pc)
UBYTE ct; /* null for b/w printers */
UWORD x, y; /* the x & y co-ordinates */
UBYTE status; /* print status (0-init, 1-enter pixel, 2-dump) */
UWORD pc; /* the # of print columns (ie. pixels) */
{
static UWORD ROWSIZE;
static UWORD BUFSIZE;
static UWORD bufptr;
UWORD i; /* mics. var */
BYTE err; /* the error # */
switch(status)
{
case 0 : /* alloc memory for printer buffer */
ROWSIZE=pc; /* row size required for EPSON */
BUFSIZE=(6+ROWSIZE); /* buffer size required for EPSON */
PD->pd_PrintBuf = (UBYTE *)
AllocMem(BUFSIZE*2,MEMF_PUBLIC); /* alloc public mem */
if (err=(PD->pd_PrintBuf == 0)) return(err);
if (err=(*(PD->pd_PWrite))("\033@",2)) return(err); /* reset printer to power-up state */
if (err=(*(PD->pd_PWrite))("\0331",2)) return(err); /* select 7/72 inch spacing */
bufptr=0;
return(0); /* flag all ok */
break;
case 1 : /* put pixel in buffer */
i = bufptr+x+4; /* calc which byte to use */
PD->pd_PrintBuf[i] = PD->pd_PrintBuf[i] | (1 << (7-(y&7))); /* fill print buffer */
return(0); /* flag all ok */
break;
case 2 : /* dump buffer to printer */
if (err=(*(PD->pd_PWrite))(&(PD->pd_PrintBuf[bufptr]), BUFSIZE)) return(err);
bufptr=BUFSIZE-bufptr;
return(0); /* flag all ok */
break;
case 3 : /* clear and init buffer */
for (i=bufptr; i<bufptr+BUFSIZE; i++)
PD->pd_PrintBuf[i] = 0; /* clear buffer */
PD->pd_PrintBuf[bufptr] = 27;
PD->pd_PrintBuf[bufptr+1] = 'L';
PD->pd_PrintBuf[bufptr+2] = ROWSIZE & 0xff;
PD->pd_PrintBuf[bufptr+3] = ROWSIZE >> 8;
PD->pd_PrintBuf[bufptr+BUFSIZE-2] = 10;
PD->pd_PrintBuf[bufptr+BUFSIZE-1] = 13;
return(0); /* flag all ok */
break;
case 4 : /* free the print buffer memory */
err=(*(PD->pd_PWrite))("\033@",2); /* reset printer to power-up state */
if (!err) err=(*(PD->pd_PBothReady))(); /* wait for both buffers to empty */
FreeMem(PD->pd_PrintBuf,BUFSIZE*2); /* free print buffer's memory */
return(err); /* return status */
break;
default: return(0);
}
}
/*********************************************************************/
TTL '$Header: printertag.asm,v 1.1 85/10/09 23:57:27 kodiak Exp $'
**********************************************************************
* *
* Copyright 1985, Commodore-Amiga Inc. All rights reserved. *
* No part of this program may be reproduced, transmitted, *
* transcribed, stored in retrieval system, or translated into *
* any language or computer language, in any form or by any *
* means, electronic, mechanical, magnetic, optical, chemical, *
* manual or otherwise, without the prior written permission of *
* Commodore-Amiga Incorporated, 983 University Ave. Building #D, *
* Los Gatos, California, 95030 *
* *
**********************************************************************
*
* printer device dependent code tag
*
* Source Control
* --------------
* $Header: printertag.asm,v 1.1 85/10/09 23:57:27 kodiak Exp $
*
* $Locker: $
*
* $Log: printertag.asm,v $
* Revision 1.1 85/10/09 23:57:27 kodiak
* replace reference to pdata w/ prtbase
*
* Revision 1.0 85/10/09 23:57:21 kodiak
* added to rcs for updating in version 1
*
* Revision 29.1 85/08/19 08:32:10 kodiak
* flag a graphics printer, not BWALPHA
*
* Revision 29.0 85/08/19 08:31:06 kodiak
* added to rcs for updating in version 29
*
* Revision 25.1 85/06/16 01:02:15 kodiak
* *** empty log message ***
*
* Revision 25.0 85/06/15 06:40:00 kodiak
* added to rcs
*
* Revision 25.0 85/06/13 18:53:36 kodiak
* added to rcs
*
*
**********************************************************************
SECTION printer
*------ Included Files -----------------------------------------------
INCLUDE "exec/types.i"
INCLUDE "exec/nodes.i"
INCLUDE "exec/strings.i"
INCLUDE "epson_rev.i"
INCLUDE "../printer/prtbase.i"
*------ Imported Names -----------------------------------------------
XREF _Init
XREF _Expunge
XREF _Open
XREF _Close
XREF _CommandTable
XREF _PrinterSegmentData
XREF _DoSpecial
XREF _Render
*------ Exported Names -----------------------------------------------
XDEF _PEDData
**********************************************************************
MOVEQ #0,D0 ; show error for OpenLibrary()
RTS
DC.W VERSION
DC.W REVISION
_PEDData:
DC.L printerName
DC.L _Init
DC.L _Expunge
DC.L _Open
DC.L _Close
DC.B PPC_BWGFX ; PrinterClass
DC.B PCC_BW ; ColorClass
DC.B 80 ; MaxColumns
DC.B 10 ; NumCharSets
DC.W 8 ; NumRows
DC.L 960 ; MaxXDots
DC.L 0 ; MaxYDots
DC.W 120 ; XDotsInch
DC.W 82 ; YDotsInch
DC.L _CommandTable ; Commands
DC.L _DoSpecial
DC.L _Render
DC.L 30
printerName:
STRING <'Epson'>
END
/* epson X80 series */
/****** printer.device/printers/Epson_functions **************************
*
* NAME
* Epson X-80 functions implemented:
*
* aRIS, aIND, aNEL, aSGR0, aSGR3, aSGR23, aSGR4, aSGR24, aSGR1, aSGR22,
* aSHORP0, aSHORP1, aSHORP2, aSHORP3, aSHORP4, aSHORP5, aSHORP6,
* aDEN1, aDEN2, aDEN3, aDEN4,
* aSUS0, aSUS1, aSUS2, aSUS3, aSUS4,
* aFNT0, aFNT1, aFNT2, aFNT3, aFNT4, aFNT5, aFNT6, aFNT7, aFNT8
* aFNT9, aFNT10,
* aPROP1, aPROP2, aJFY5, aJFY7, aJFY6, aJFY0, aJFY3, aJFY2,
* aVERP0, aVERP1, aSLPP, aPERF, aPERF0,
* aTBC3, aTBC4, aTBCALL, aTBSALL
*
* special functions implemented:
*
* aRIN, aSUS0, aSUS1, aSUS2, aSUS3, aSUS4,
* aPLU, aPLD, aVERP0, aVERP1, aSLRM, aIND, aCAM
*
************************************************************************/
char *CommandTable[] ={
"\033@", /*reset RIS ESCc */
"\377", /*initialize*/
"\012", /* lf IND ESCD */
"\015\012", /* return,lf NEL ESCE */
"\377", /* reverse lf RI ESCM */
/*normal char set SGR 0 ESC[0m */
"\0335\033-\376\033F",
"\0334", /*italics on SGR 3 ESC[3m */
"\0335", /*italics off SGR 23 ESC[23m */
"\033-\001", /*underline on SGR 4 ESC[4m */
"\033-\376", /*underline off SGR 24 ESC[24m */
"\033E", /*boldface on SGR 1 ESC[1m */
"\033F", /*boldface off SGR 22 ESC[22m */
"\377", /* set foreground color */
"\377", /* set background color */
/* normal char set SHORP ESC[0w */
"\033P\033\022\033W\376",
"\033M", /*elite on SHORP ESC[2w */
"\033P", /*elite off SHORP ESC[1w */
"\017", /*condensed(fine) on SHORP ESC[4w */
"\022", /*condensed off SHORP ESC[3w */
"\033W\001", /*enlarged on SHORP ESC[6w */
"\033W\376", /*enlarged off SHORP ESC[5w */
"\377", /*shadow print on DEN6 ESC[6"z */
"\377", /*shadow print off DEN5 ESC[5"z */
"\033G", /*doublestrike on DEN4 ESC[4"z */
"\033H", /*doublestrike off DEN3 ESC[3"z */
"\033x\001", /* NLQ on DEN2 ESC[2"z */
"\033x\376", /* NLQ off DEN1 ESC[1"z */
"\033S\376", /*superscript on ESC[2u */
"\033T", /*superscript off ESC[1u */
"\033S\001", /*subscript on ESC[4u */
"\033T", /*subscript off ESC[3u */
"\033T", /*normalize ESC[0u */
"\377", /* partial line up PLU ESCL */
"\377", /* partial line down PLD ESCK */
"\033R\376", /*US char set FNT0 ESC(B */
"\033R\001", /*French char set FNT1 ESC(R */
"\033R\002", /*German char set FNT2 ESC(K */
"\033R\003", /*UK char set FNT3 ESC(A */
"\033R\004", /*Danish I char set FNT4 ESC E */
"\033R\005", /*Sweden char set FNT5 ESC(H */
"\033R\006", /*Italian char set FNT6 ESC(Y */
"\033R\007", /*Spanish char set FNT7 ESC(Z */
"\033R\010", /*Japanese char set FNT8 ESC(J */
"\033R\011", /*Norweign char set FNT9 ESC(6 */
"\033R\012", /*Danish II char set FNT10 ESC(C */
"\033p\001", /*proportional on PROP ESC[2p */
"\033p\376", /*proportional off PROP ESC[1p */
"\377", /*proportional clear PROP ESC[0p */
"\377", /*set prop offset TSS */
"\033a\376", /*auto left justify JFY5 ESC[5 F */
"\033a\002", /*auto right justify JFY7 ESC[7 F */
"\033a\003", /*auto full justify JFY6 ESC[6 F */
"\033x\376", /*auto justify/center off ESC[0 F */
"\377", /*place holder JFY3 ESC[3 F */
"\033a\001", /*auto center on JFY2 ESC[2 F */
"\0330", /* 1/8" line space VERP ESC[0z */
"\0332", /* 1/6" line spacing VERP ESC[1z */
"\033C", /* set form length SLPP ESC[Pnt */
"\033N", /* perf skip n ESC[nq */
"\033O", /* perf skip off ESC[0q */
"\377", /* Left margin set ESC[2x */
"\377", /* Right margin set ESC[3x */
"\377", /* top margin set ESC[4x */
"\377", /* Bottom marg set ESC[5x */
"\377", /* T&B margin set STBM ESC[Pn1;Pn2r */
"\377", /* L&R margin set SLRM ESC[Pn1;Pn2s */
"\377", /* Clear margins ESC[0x */
"\377", /* Set horiz tab HTS ESCH */
"\377", /* Set vertical tab VTS ESCJ */
"\377", /* Clr horiz tab TBC 0 ESC[0g */
/* Clear all h tabs TBC 3 ESC[3g */
"\377", /* "\033D\376", */
"\377", /* Clr vertical tab TBC 1 ESC[1g */
/* Clr all v tabs TBC 4 ESC[4g */
"\377", /* "\033B\376", */
/* Clr all h & v tabs ESC#4 */
"\377", /*"\033D\376\033B\376", */
"\377", /* set default tabs */
/* "\033D\011\021\031\041\051\061\071\101\111\121\131\376", */
"\377" /* entended command */
};
/* epson X80 special commands */
/****** printer.device/printers/Epson_special_functions ******************
*
* NAME
* Epson X80 special functions
*
************************************************************************/
#include "exec/types.h"
#include "../printer/printer.h"
#include "../printer/prtbase.h"
extern struct PrinterData *PD;
DoSpecial(command,outputBuffer,vline,currentVMI,crlfFlag,Parms)
char outputBuffer[];
UWORD *command;
BYTE *vline;
BYTE *currentVMI;
BYTE *crlfFlag;
UBYTE Parms[];
{
int x=0;
int y=0;
static char initMarg[]="\033lL\033Qq\033Q\120\033Q\210\033Q\240";
static char
initThisPrinter[]="\033x\001\0332\033\022\0335\033P\033-\376\033F\n\033W";
if(*command==aRIN) {
while(x<19){outputBuffer[x]=initThisPrinter[x];x++;}
outputBuffer[x++]='\000';
outputBuffer[13]='\000';
if((PD->pd_Preferences.PrintQuality)==DRAFT)outputBuffer[2]='\000';
*currentVMI=36; /* assume 1/6 line spacing */
if((PD->pd_Preferences.PrintSpacing)==EIGHT_LPI) { /* wrong again */
outputBuffer[4]='0';
*currentVMI=27;
}
if ((PD->pd_Preferences.PrintPitch) != PICA)outputBuffer[x++]='\033';
if((PD->pd_Preferences.PrintPitch)==ELITE)outputBuffer[x++]='M';
else if((PD->pd_Preferences.PrintPitch)==FINE)
outputBuffer[x++]='\017';
Parms[0]=(PD->pd_Preferences.PrintLeftMargin);
Parms[1]=(PD->pd_Preferences.PrintRightMargin);
*command=aSLRM;
}
if(*command==aSLRM) {
initMarg[2]=Parms[0];
initMarg[5]=Parms[1]+1;
while(y<6)outputBuffer[x++]=initMarg[y++];
return(x);
}
if(*command==aCAM) {
initMarg[2]=1;
initMarg[5]=80;
while(y<15)outputBuffer[x++]=initMarg[y++];
return(x);
}
if(*command==aPLU) {
if((*vline)==0){(*vline)=1; *command=aSUS2; return(0);}
if((*vline)<0){(*vline)=0; *command=aSUS3; return(0);}
return(-1);
}
if(*command==aPLD) {
if((*vline)==0){(*vline)=(-1); *command=aSUS4; return(0);}
if((*vline)>0){(*vline)=0; *command=aSUS1; return(0);}
return(-1);
}
if(*command==aSUS0) *vline=0;
if(*command==aSUS1) *vline=0;
if(*command==aSUS2) *vline=1;
if(*command==aSUS3) *vline=0;
if(*command==aSUS4) *vline=(-1);
if(*command==aVERP0) *currentVMI=27;
if(*command==aVERP1) *currentVMI=36;
if(*command==aIND) {
outputBuffer[x++]='\033';
outputBuffer[x++]='J';
outputBuffer[x++]= *currentVMI;
return(x);
}
return(0);
}
/*********************************************************************/
#include <exec/types.h>
#include <exec/nodes.h>
#include <exec/lists.h>
#include <exec/memory.h>
#include "../printer/prtbase.h"
#include "../printer/printer.h"
extern struct PrinterData *PD;
extern struct PrinterExtendedData *PED;
extern SetDensity();
char density[8] = "\033*t100R";
/* for the HP+ 2686A */
int Render(ct, x, y, status, pc)
UBYTE ct; /* null for b/w printers */
UWORD x, y; /* the x & y co-ordinates */
UBYTE status; /* print status (0-init, 1-enter pixel, 2-dump, 3-close, 4-end) */
UWORD pc; /* the # of print columns (ie. pixels) */
{
static UWORD ROWSIZE;
static UWORD BUFSIZE;
static BYTE huns,tens,ones; /* used to program buffer size */
static UWORD bufptr; /* used for double buffering; points to buffer 1 or 2 */
UWORD i; /* mics. var */
BYTE err; /* the error # */
#ifdef DEBUG
kprintf("hp render(%ld, %ld, %ld, %ld, %ld);\n", ct, x, y, status, pc);
#endif
switch(status)
{
case 0 : /* alloc memory for printer buffer (uses double buffering) */
ROWSIZE=(pc+7)/8; /* row size required for HP */
huns=ROWSIZE/100;
tens=(ROWSIZE-huns*100)/10;
ones=(ROWSIZE-huns*100-tens*10);
BUFSIZE=(ROWSIZE+7); /* buffer size required for HP */
PD->pd_PrintBuf = (UBYTE *)
AllocMem(BUFSIZE*2,MEMF_PUBLIC); /* alloc public mem */
if (err=(PD->pd_PrintBuf == 0)) return(err);
if (err=(*(PD->pd_PWrite))("\033E",2)) return(err); /* reset printer */
if (err=(*(PD->pd_PWrite))(density,7)) return(err); /* set resolution */
if (err=(*(PD->pd_PWrite))("\033*r0A",5)) return(err); /* start raster gfx */
bufptr=0; /* init to first buffer */
return(0); /* flag all ok */
break;
case 1 : /* put pixel in buffer */
i = bufptr+x/8+7; /* calc which byte to use */
PD->pd_PrintBuf[i] = PD->pd_PrintBuf[i] | (1 << (7-(x&7))); /* fill print buffer */
return(0); /* flag all ok */
break;
case 2 : /* dump buffer to printer */
if (err=(*(PD->pd_PWrite))(&(PD->pd_PrintBuf[bufptr]), BUFSIZE)) return(err);
bufptr=BUFSIZE-bufptr; /* switch to other buffer */
return(0); /* flag all ok */
break;
case 3 : /* clear and init buffer */
for (i=bufptr; i<BUFSIZE+bufptr; i++)
PD->pd_PrintBuf[i] = 0; /* clear buffer */
PD->pd_PrintBuf[bufptr] = 27;
PD->pd_PrintBuf[bufptr+1] = '*';
PD->pd_PrintBuf[bufptr+2] = 'b';
PD->pd_PrintBuf[bufptr+3] = huns + '0';
PD->pd_PrintBuf[bufptr+4] = tens + '0';
PD->pd_PrintBuf[bufptr+5] = ones + '0';
PD->pd_PrintBuf[bufptr+6] = 'W';
return(0); /* flag all ok */
break;
case 4 : /* free the print buffer memory */
/* end raster graphics, unload paper, and reset printer */
err=(*(PD->pd_PWrite))("\033*rB\014\033E",7);
if (!err) err=(*(PD->pd_PBothReady))(); /* wait for both buffers to be clear */
FreeMem(PD->pd_PrintBuf,BUFSIZE*2); /* free the print buffers memory */
return(err); /* return status */
break;
case 5:
if ((pc & SPECIAL_DENSITYMASK) == 0) { /* if use prefs */
if (PD->pd_Preferences.PrintQuality == DRAFT)
SetDensity(SPECIAL_DENSITY2); /* 100 dpi */
else SetDensity(SPECIAL_DENSITY3); /* 150 dpi */
}
else SetDensity(pc & SPECIAL_DENSITYMASK); /* else use SPECIAL */
return(0);
break;
default :
return(0);
break;
}
}
/*********************************************************************/
TTL '$Header: printertag.asm,v 1.2 85/10/09 23:58:23 kodiak Exp $'
**********************************************************************
* *
* Copyright 1985, Commodore-Amiga Inc. All rights reserved. *
* No part of this program may be reproduced, transmitted, *
* transcribed, stored in retrieval system, or translated into *
* any language or computer language, in any form or by any *
* means, electronic, mechanical, magnetic, optical, chemical, *
* manual or otherwise, without the prior written permission of *
* Commodore-Amiga Incorporated, 983 University Ave. Building #D, *
* Los Gatos, California, 95030 *
* *
**********************************************************************
*
* printer device dependent code tag
*
* Source Control
* --------------
* $Header: printertag.asm,v 1.2 85/10/09 23:58:23 kodiak Exp $
*
* $Locker: $
*
* $Log: printertag.asm,v $
* Revision 1.2 85/10/09 23:58:23 kodiak
* replace reference to pdata w/ prtbase
*
* Revision 1.1 85/10/09 16:11:31 kodiak
* daveb density changes
*
* Revision 25.1 85/06/16 01:02:15 kodiak
* *** empty log message ***
*
* Revision 25.0 85/06/15 06:40:00 kodiak
* added to rcs
*
* Revision 25.0 85/06/13 18:53:36 kodiak
* added to rcs
*
*
**********************************************************************
SECTION printer
*------ Included Files -----------------------------------------------
INCLUDE "exec/types.i"
INCLUDE "exec/nodes.i"
INCLUDE "exec/strings.i"
INCLUDE "hpplus_rev.i"
INCLUDE "../printer/prtbase.i"
*------ Imported Names -----------------------------------------------
XREF _Init
XREF _Expunge
XREF _Open
XREF _Close
XREF _CommandTable
XREF _PrinterSegmentData
XREF _DoSpecial
XREF _Render
*------ Exported Names -----------------------------------------------
XDEF _PEDData
**********************************************************************
MOVEQ #0,D0 ; show error for OpenLibrary()
RTS
DC.W VERSION
DC.W REVISION
_PEDData:
DC.L printerName
DC.L _Init
DC.L _Expunge
DC.L _Open
DC.L _Close
DC.B PPC_BWGFX ; PrinterClass
DC.B PCC_BW ; ColorClass
DC.B 0 ; MaxColumns
DC.B 0 ; NumCharSets
DC.W 1 ; NumRows
DC.L 800 ; MaxXDots
DC.L 1020 ; MaxYDots
DC.W 100 ; XDotsInch
DC.W 100 ; YDotsInch
DC.L _CommandTable ; Commands
DC.L _DoSpecial
DC.L _Render
DC.L 30
printerName:
STRING <'HP LaserJet Plus'>
END
/* HP command table */
/****** printer.device/HP_LaserJet_Plus_functions ************************
*
* NAME
* HP LaserJet 2686A functions implemented:
*
* aRIS, aIND, aNEL,
* aSGR0, aSGR3, aSGR23, aSGR4, aSGR24, aSGR1, aSGR22,
* aSHORP0, aSHORP1, aSHORP2, aSHORP3, aSHORP4
* aDEN3, aDEN4, aPLU, aPLD,
* aFNT0, aFNT3, aFNT8,
* aPROP0, aPROP1, aPROP2,
* aVERP0, aVERP1, aPERF, aPERF0, aCAM
*
************************************************************************/
char *CommandTable[]={
"\033E", /*reset*/
"\377", /*initialize*/
"\012", /* lf IND ESCD */
"\015\012", /* return,lf NEL ESCE */
"\033&a-1R",
/* reverse lf RI ESCM */
"\033&d@\033(sbS", /*normal char set SGR 0 */
"\033(s1S", /*italics on*/
"\033(sS", /*italics off*/
"\033&dD", /*underline on*/
"\033&d@", /*underline off */
"\033(s3B", /*boldface on*/
"\033(sB", /*boldface off*/
"\377", /* set foreground color */
"\377", /* set background color */
"\033(s10h1T", /* normal pitch */
"\033(s12h2T", /* elite on*/
"\033(s10h1T", /* elite off*/
"\033(s15H",/* condensed on*/
"\033(s10H",/* condensed off*/
"\377", /* enlarged on*/
"\377", /* enlarged off*/
"\033(s7B", /*shadow print on*/
"\033(sB", /*shadow print off*/
"\033(s3B", /*doublestrike on*/
"\033(sB", /*doublestrike off*/
"\377", /* NLQ on*/
"\377", /* NLQ off*/
"\377", /*superscript on*/
"\377", /*superscript off*/
"\377", /*subscript on*/
"\377", /*subscript off*/
"\377", /* normalize */
"\033&a-.5R", /* partial line up PLU ESCL */
"\033=", /* partial line down PLD ESCK */
"\033(U", /*US char set */
"\033(F", /*French char set*/
"\033(G", /*German char set*/
"\033(1E", /*UK char set*/
"\033(D", /*Danish I char set*/
"\033(S", /*Sweden char set*/
"\033(I", /*Italian char set*/
"\033(1S", /*Spanish char set*/
"\033(8K", /*Japanese char set*/
"\033(D", /*Norweigen char set*/
"\033(D", /*Danish II char set*/
"\033(s1P", /*proportional on*/
"\033(sP", /*proportional off*/
"\033(sP", /*proportional clear*/
"\377", /*set prop offset*/
"\377", /*auto left justify on*/
"\377", /*auto right justify on*/
"\377", /*auto full justify on*/
"\377", /*auto justify/center off*/
"\377", /*place holder */
"\377", /*auto center on*/
"\033&l8D", /* 1/8" line space*/
"\033&l6D", /* 1/6" line spacing*/
"377", /* set form length n */
"\033&l1L", /* perf skip n */
"\033&lL", /* Perf skip off */
"\0334", /* Left margin set */
"\0335", /* Right margin set */
"\377", /* Top margin set */
"\377", /* Bottom marg set */
"\377", /* T&B margin set STBM ESC[Pn1;Pn2r */
"\377", /* L&R margin set SLRM ESC[Pn1;Pn2s */
"\0339", /* Clear margins */
"\0331", /* Set horiz tab */
"\377", /* Set vertical tab */
"\0332", /* Clr horiz tab */
"\0333", /* Clear all h tabs */
"\377", /* Clear vertical tab */
"\377", /* Clr all v tabs TBC 4 */
"\377", /* Clr all h & v tabs */
"\377", /* set default tabs */
"\377" /* extended commands */
};
/* hp special printer functions */
/****** printer.device/printers/HP_LaserJet_Plus_special_functions *******
*
* NAME
* HP LaserJet 2686A special functions implemented:
*
* aRIN,
* aSUS0, aSUS1, aSUS2, aSUS3, aSUS4
* aPLU, aPLD, aVERP0, aVERP1,
* aSLPP, aSLRM, aSTBM
*
************************************************************************/
#include "exec/types.h"
#include "../printer/printer.h"
#include "../printer/prtbase.h"
extern struct PrinterData *PD;
DoSpecial(command,outputBuffer,vline,currentVMI,crlfFlag,Parms)
char outputBuffer[];
UWORD *command;
BYTE *vline;
BYTE *currentVMI;
BYTE *crlfFlag;
UBYTE Parms[];
{
int x=0;
int y=0;
int j=0;
static char initThisPrinter[]="\033&d@\033&l6D\033(sb10hps1tu12V";
static char initMarg[]="\033&a000l000M";
static char initTMarg[]="\033&l000e000F";
static char initForm[]="\033&l000P";
if(*command==aRIN) {
while(x<24){outputBuffer[x]=initThisPrinter[x];x++;}
if((PD->pd_Preferences.PrintSpacing)==EIGHT_LPI) { /* wrong again */
outputBuffer[7]='8';
}
if((PD->pd_Preferences.PrintPitch)==ELITE) {
outputBuffer[14]='2';
outputBuffer[18]='2';
}
if((PD->pd_Preferences.PrintPitch)==FINE) {
outputBuffer[14]='5';
}
Parms[0]=(PD->pd_Preferences.PrintLeftMargin);
Parms[1]=(PD->pd_Preferences.PrintRightMargin);
*command=aSLRM;
}
if(*command==aSLRM) {
j=x;
while(y<11)outputBuffer[x++]=initMarg[y++];
numberString(Parms[0]-1,j+3,outputBuffer);
numberString(Parms[1]-1,j+7,outputBuffer);
return(x);
}
if((*command==aSUS2)&&(*vline==0)) {*command=aPLU; *vline=1; return(0);}
if((*command==aSUS2)&&(*vline<0)) {*command=aRI; *vline=1; return(0);}
if((*command==aSUS1)&&(*vline>0)) {*command=aPLD; *vline=0; return(0);}
if((*command==aSUS4)&&(*vline==0)) {*command=aPLD; *vline=(-1); return(0);}
if((*command==aSUS4)&&(*vline>0)) {*command=aIND; *vline=(-1); return(0);}
if((*command==aSUS3)&&(*vline<0)) {*command=aPLU; *vline=0; return(0);}
if(*command==aSUS0)
{
if(*vline>0) *command=aPLD;
if(*vline<0) *command=aPLU;
*vline=0;
return(0);
}
if(*command==aPLU){(*vline)++; return(0);}
if(*command==aPLD){(*vline)--; return(0);}
if(*command==aSTBM)
{
while(x<11){outputBuffer[x]=initTMarg[x]; x++;}
numberString(Parms[0],3,outputBuffer);
numberString(Parms[1]-Parms[0],7,outputBuffer);
return(x);
}
if(*command==aSLPP) {
while(x<7){outputBuffer[x]=initForm[x]; x++;}
numberString(Parms[0],3,outputBuffer);
return(x);
}
return(0);
}
VOID
numberString(Param,x,outputBuffer)
BYTE Param;
int x;
char outputBuffer[];
{
if(Param>199){outputBuffer[x++]='2'; Param-=200;}
else if(Param>99){outputBuffer[x++]='1'; Param-=100;}
else outputBuffer[x++]='0'; /* always return 3 digits */
if(Param>9)outputBuffer[x++]=(BYTE)(Param/10)+'0';
else outputBuffer[x++]='0';
outputBuffer[x++]=Param%10+'0';
}
Close()
{
(*(PD->pd_PWrite))("\033E",2);
(*(PD->pd_PBothReady))();
return(0);
}
/*
***** density.c *****
*/
#include <exec/types.h>
#include "../printer/prtbase.h"
#include "../printer/printer.h"
extern struct PrinterExtendedData *PED;
extern char density[];
SetDensity(level)
UWORD level;
{
switch (level) {
case SPECIAL_DENSITY1:
PED->ped_MaxXDots = 600;
PED->ped_MaxYDots = 795;
PED->ped_XDotsInch = PED->ped_YDotsInch = 75;
density[3] = '0';
density[4] = '7';
density[5] = '5';
break;
case SPECIAL_DENSITY2:
PED->ped_MaxXDots = 800;
PED->ped_MaxYDots = 1060;
PED->ped_XDotsInch = PED->ped_YDotsInch = 100;
density[3] = '1';
density[4] = '0';
density[5] = '0';
break;
case SPECIAL_DENSITY3:
PED->ped_MaxXDots = 1200;
PED->ped_MaxYDots = 1590;
PED->ped_XDotsInch = PED->ped_YDotsInch = 150;
density[3] = '1';
density[4] = '5';
density[5] = '0';
break;
case SPECIAL_DENSITY4:
PED->ped_MaxXDots = 2400;
PED->ped_MaxYDots = 3180;
PED->ped_XDotsInch = PED->ped_YDotsInch = 300;
density[3] = '3';
density[4] = '0';
density[5] = '0';
break;
default: break;
}
}
/*********************************************************************/